﻿/*
*######################################
* eWebEditor v7.0 - Advanced online web based WYSIWYG HTML editor.
* Copyright (c) 2003-2011 eWebSoft.com
*
* For further information go to http://www.ewebeditor.net/
* This copyright notice MUST stay intact for use.
*######################################
*/

var bV = new Object();
var hn = document.location.search.substr(1).split('&');
for (i = 0; i < hn.length; i++) {
    var hh = hn[i].split('=');
    bV[hh[0]] = hh[1];
}
var EWIN = parent.EWIN;
var A = EWIN.A;
var cZ = EWIN.cZ;
var C = EWIN.C;
var O = EWIN.O;
var ag = EWIN.ag;
var lang = EWIN.lang;
var config = EWIN.config;
var I = EWIN.I;
var ck = parent.ck();
if (ck) {
    ck = ck.contentWindow.vO;
}
C.lk(window);
function ms(bn, aa) {
    return (bV[bn]) ? bV[bn] : aa;
};
function jf(url) {
    document.write('<scr' + 'ipt type="text/javascript" src="' + url + '"><\/scr' + 'ipt>');
};
function dX(T) {
    mJ = 0;
    mS = T.length;
    if (dX.arguments.length == 2) {
        kN = dX.arguments[1].toLowerCase();
    } else {
        kN = "all";
    }
    for (var i = 0; i < T.length; i++) {
        uQ = T.substring(mJ, mJ + 1);
        uS = T.substring(mS, mS - 1);
        if ((kN == "all" || kN == "left") && uQ == " ") {
            mJ++;
        }
        if ((kN == "all" || kN == "right") && uS == " ") {
            mS--;
        }
    }
    T = T.slice(mJ, mS);
    return T;
};
function cv(rF, wb) {
    alert(wb);
    rF.focus();
    rF.select();
    return false;
};
function lU(color) {
    var qP = color;
    if (qP == "") return true;
    if (qP.length != 7) return false;
    return (qP.search(/\#[a-fA-F0-9]{6}/) != -1);
};
function ws(T) {
    return (T.search(/[^0-9]+/) == -1);
};
function xv(T) {
    return (ws(T) && parseInt(T) > 0);
};
function et(e) {
    if (!e) {
        e = window.event;
    }
    if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 35 && e.keyCode <= 40) || e.keyCode == 46 || e.keyCode == 8) {
        return true;
    }
    return C.aR(e);
};
function fX(oG) {
    var R = "selcolor.htm?returnfieldflag=" + oG;
    cZ.OpenDialog(R);
};
function sv() {
    cZ.OpenDialog("backimage.htm?action=other");
};
function xQ(type, oG) {
    cZ.OpenDialog('browse.htm?returnfieldflag=' + oG + '&type=' + type);
};
function bb(pM, aa) {
    for (var i = 0; i < pM.length; i++) {
        if (pM.options[i].value == aa) {
            pM.selectedIndex = i;
            return true;
        }
    }
    return false;
};
function du(T) {
    T = dX(T);
    if (T != "") {
        var eI = parseFloat(T);
        if (isNaN(eI)) {
            T = "";
        } else {
            T = eI;
        }
    }
    return T;
};
function wr(url) {
    var eI;
    var b = true;
    eI = url.substring(0, 7);
    eI = eI.toUpperCase();
    if ((eI != "HTTP://") || (url.length < 10)) {
        b = false;
    }
    return b;
};
function hw(url, kM) {
    var eI;
    var b = false;
    var s = kM.toUpperCase().split("|");
    for (var i = 0; i < s.length; i++) {
        eI = url.substr(url.length - s[i].length - 1);
        eI = eI.toUpperCase();
        s[i] = "." + s[i];
        if (s[i] == eI) {
            b = true;
            break;
        }
    }
    return b;
};
function pI(R) {
    if (R.substring(0, 1) == "/") {
        return R;
    }
    if (R.indexOf("://") >= 0) {
        return R;
    }
    var mW = A.bF;
    while (R.substr(0, 3) == "../") {
        R = R.substr(3);
        mW = mW.substring(0, mW.lastIndexOf("/"));
    }
    return mW + "/" + R;
};
function nk(R) {
    if (config.BaseHref == "") {
        return R;
    }
    if (R.substring(0, 1) == "/") {
        return R;
    }
    if (R.indexOf("://") >= 0) {
        return R;
    }
    var iI = config.BaseHref;
    iI = iI.substring(0, iI.length - 1);
    while (R.substring(0, 3) == "../") {
        R = R.substr(3);
        iI = iI.substring(0, iI.lastIndexOf("/"));
    }
    return iI + "/" + R
};
function wf(R) {
    var lS = A.bF + "/plugin/";
    while (true) {
        var cp = R.indexOf("/");
        var eA = lS.indexOf("/");
        if (cp >= 0 && cp == eA) {
            if (R.substring(0, cp + 1) == lS.substring(0, eA + 1)) {
                R = R.substr(cp + 1);
                lS = lS.substr(eA + 1);
            } else {
                break;
            }
        } else {
            break;
        }
    }
    var s = lS.replace(/[^\/]+/gi, '');
    var n = s.length;
    for (var i = 0; i < n; i++) {
        R = "../" + R;
    }
    return R;
};
function fH(url) {
    switch (config.BaseUrl) {
    case "0":
        url = pI(url);
        return xf(url);
        break;
    case "1":
        return pI(url);
        break;
    case "2":
    case "3":
        return A.gY + pI(url);
        break;
    }
};
function xf(url) {
    var jG = config.BaseHref;
    var b = true;
    while (b) {
        var cp = url.indexOf("/");
        var eA = jG.indexOf("/");
        if ((cp >= 0) && (eA >= 0)) {
            var vg = url.substring(0, cp + 1);
            var vi = jG.substring(0, eA + 1);
            if (vg == vi) {
                url = url.substr(cp + 1);
                jG = jG.substr(eA + 1);
            } else {
                b = false;
            }
        } else {
            b = false;
        }
    }
    if (jG != "") {
        var a = jG.split("/");
        for (var i = 1; i < a.length; i++) {
            url = "../" + url;
        }
    }
    return url;
};
function xq() {
    var w = tabDialogSize.offsetWidth + 6;
    var h = tabDialogSize.offsetHeight + 25;
    if (O.xp) {
        h += 20;
    }
    window.dialogWidth = w + "px";
    window.dialogHeight = h + "px";
    window.dialogLeft = (screen.availWidth - w) / 2;
    window.dialogTop = (screen.availHeight - h) / 2;
};
function imgButtonOver(t) {
    if (!t["imageinitliazed"]) {
        t["oncontextmenu"] = new Function("event.returnValue=false");
        t["onmouseout"] = new Function("imgButtonOut(this)");
        t["onmousedown"] = new Function("imgButtonDown(this)");
        t["unselectable"] = "on";
        t["imageinitliazed"] = true;
    }
    t.className = "imgButtonOver";
};
function imgButtonOut(t) {
    t.className = "imgButtonOut";
};
function imgButtonDown(t) {
    t.className = "imgButtonDown";
};
function jL(cc) {
    var mb;
    switch (cc) {
    case "image":
        mb = config.AllowImageSize;
        break;
    case "flash":
        mb = config.AllowFlashSize;
        break;
    case "media":
        mb = config.AllowMediaSize;
        break;
    case "file":
        mb = config.AllowFileSize;
        break;
    default:
        return "";
    }
    var wG = parseFloat(mb) * 1024;
    var html = "<iframe name='myuploadformtarget' style='display:none;position:absolute;width:0px;height:0px' src='blank.htm'></iframe>" + "<form action='../" + config.ServerExt + "/upload." + config.ServerExt + "?action=save&type=" + cc + "&style=" + ag.StyleName + "&cusdir=" + ag.CusDir + "&skey=" + ag.SKey + "' method=post name=myuploadform enctype='multipart/form-data' style='margin:0px;padding:0px;width:100%;border:0px;' target='myuploadformtarget'>" + "<input type=hidden name='MAX_FILE_SIZE' value='" + wG + "'>" + "<input type=file name='uploadfile' id='uploadfile' size=28  onchange=\"this.form.originalfile.value=this.value;try{xN();} catch(e){}\">" + "<input type=hidden name='originalfile' value=''>" + "</form>";
    return html;
};
function jF(an, cy, ut) {
    var iA = "";
    switch (an) {
    case "ext":
        iA = lang["ErrUploadInvalidExt"] + ":" + cy;
        break;
    case "size":
        iA = lang["ErrUploadSizeLimit"] + ":" + ut + "KB";
        break;
    case "file":
        iA = lang["ErrUploadInvalidFile"];
        break;
    case "style":
        iA = lang["ErrInvalidStyle"];
        break;
    case "space":
        iA = lang["ErrUploadSpaceLimit"] + ":" + config.SpaceSize + "MB";
        break;
    default:
        iA = an;
        break;
    }
    return iA;
};
function nr(bn) {
    var sj = "";
    var jN = bn + "=";
    if (document.cookie.length > 0) {
        mY = document.cookie.indexOf(jN);
        if (mY != -1) {
            mY += jN.length;
            var eE = document.cookie.indexOf(";", mY);
            if (eE == -1) {
                eE = document.cookie.length;
            }
            sj = unescape(document.cookie.substring(mY, eE));
        }
    }
    return sj;
};
function np(bn, aa) {
    var nd = "";
    nd = new Date((new Date()).getTime() + 24 * 365 * 3600000);
    nd = ";expires=" + nd.toGMTString();
    document.cookie = bn + "=" + escape(aa) + nd;
};
var U;
function dz(kF) {
    if (U) {
        U = null;
    }
    var b = false;
    try {
        U = new ActiveXObject("eWebSoft.eWebEditor3");
        var lA = U.Version;
        if (parseFloat(lA.replace(/[^0123456789]+/gi, "")) >= 3000) {
            U.Lang = lang.ax;
            U.SendUrl = A.SendUrl;
            U.LocalSize = config.AllowLocalSize;
            U.LocalExt = config.AllowLocalExt;
            b = true;
        }
    } catch(e) {}
    if (!b && kF) {
		//2013/08/20 wchen hidden
        //cZ.OpenDialog("installactivex.htm", true);
		null;
    }
    return b;
};
function ef() {
    var dr = U.Error;
    if (dr != "") {
        var fG, fE;
        if (dr.indexOf(":") >= 0) {
            var a = dr.split(":");
            fG = a[0];
            fE = a[1];
        } else {
            fG = dr;
            fE = "";
        }
        switch (fG) {
        case "L":
            alert(lang["ErrLicense"]);
            break;
        case "InvalidFile":
            alert(lang["ErrInvalidFile"] + ":" + fE);
            break;
        default:
            alert(dr);
        }
        return true;
    }
    return false;
};
function bm(t, ct, gI) {
    if (gI == null || gI.length == 0) {
        t.removeAttribute(ct, 0);
    } else {
        t.setAttribute(ct, gI, 0);
    }
};
function jZ(t, aV, fb) {
    bm(t, "_ewebeditor_ta_" + aV, encodeURIComponent(fb));
};
function bU(t, ct) {
    var oR = t.attributes[ct];
    if (oR == null || !oR.specified) {
        return "";
    }
    var mF = t.getAttribute(ct, 2);
    if (mF == null) {
        mF = oR.nodeValue;
    }
    return (mF == null ? "": mF);
};
function dE(t, ct) {
    ct = ct.replace(/\-(\w)/g,
    function(xu, pb) {
        return pb.toUpperCase();
    });
    var aa = t.style[ct];
    if (aa && (!O.ae) && ct.indexOf("Color") >= 0) {
        aa = wh(aa);
    }
    if (!aa) {
        switch (ct) {
        case "backgroundColor":
            ct = "bgColor";
            break;
        case "textAlign":
            ct = "align";
            break;
        case "verticalAlign":
            ct = "valign";
            break;
        default:
        }
        aa = bU(t, ct);
    }
    return aa;
};
function jV(aa) {
    var n = parseInt(aa);
    if (isNaN(n)) {
        return '';
    }
    if (aa.substr(aa.length - 1) != "%") {
        aa = n + "";
    }
    return aa;
};
function sp(t, aV) {
    var rI = "_ewebeditor_ta_" + aV;
    var sN = t.attributes[rI];
    if (sN == null || !sN.specified) {
        return bU(t, aV);
    } else {
        return decodeURIComponent(t.getAttribute(rI, 2));
    }
};
function rX(t) {
    return bU(t, "_ewebeditor_fake_tag");
};
function rZ(t) {
    return decodeURIComponent(bU(t, "_ewebeditor_fake_value"));
};
function wg(t, f) {
    bm(t, '_ewebeditor_fake_value', encodeURIComponent(f));
};
function pF(N) {
    if (N == null) return "00";
    N = parseInt(N);
    if (N == 0 || isNaN(N)) return "00";
    N = Math.max(0, N);
    N = Math.min(N, 255);
    N = Math.round(N);
    return "0123456789ABCDEF".charAt((N - N % 16) / 16) + "0123456789ABCDEF".charAt(N % 16);
};
function wh(T) {
    if (T.substring(0, 3) == 'rgb') {
        var aN = T.split(",");
        var r = aN[0].replace('rgb(', '').trim();
        var g = aN[1].trim();
        var b = aN[2].replace(')', '').trim();
        var uA = [pF(r), pF(g), pF(b)];
        return "#" + uA.join('');
    } else {
        return T;
    }
};
var bg = {
    Init: function(f) {
        this.mD = new Object();
        this.rA = f;
        var P = new RegExp("<object(?=[\\s>])", "gi");
        if (P.test(f)) {
            this.ka = "object";
            P = /<param\s+name\s*?=\s*?([\'\"]?)(\w+)\1[\s]+value\s*?=\s*?(\w+|\'[^\'>]+\'|\"[^\">]+\")[^>]*?>/gi;
            while ((aN = P.exec(f)) != null) {
                var ei = RegExp.$3;
                if (ei.substring(0, 1) == '\'' || ei.substring(0, 1) == '"') {
                    ei = ei.substring(1, ei.length - 1);
                }
                this.mD[RegExp.$2.toLowerCase()] = ei;
            }
        } else {
            this.ka = "common";
            P = /\s(\w+)\s*?=\s*?(\w+|\'[^\'>]+\'|\"[^\">]+\")/gi;
            while ((aN = P.exec(f)) != null) {
                var ei = RegExp.$2;
                if (ei.substring(0, 1) == '\'' || ei.substring(0, 1) == '"') {
                    ei = ei.substring(1, ei.length - 1);
                }
                this.mD[RegExp.$1.toLowerCase()] = ei;
            }
        }
    },
    cl: function(aF) {
        return (this.mD[aF]) ? this.mD[aF] : "";
    },
    ww: function() {
        return this.rA;
    },
    hq: function(aF, aa) {
        var f = this.rA;
        function eZ(m, cN) {
            if (aa == '') {
                return '';
            } else {
                return '<param name="' + aF + '" value="' + aa + '">';
            }
        };
        function fi(m) {
            return m + '<param name="' + aF + '" value="' + aa + '">';
        };
        if (this.ka == 'object') {
            var P = new RegExp('<param(?=\\s)[^>]*?\\sname\\s*?=\\s*?(\w+|\'[^\'>]+\'|\"[^\">]+\")[^>]*?>', 'gi');
            if (P.test(f)) {
                f = f.replace(P, eZ);
            } else {
                if (aa != '') {
                    f = f.replace(/<object[^>]*?>/, fi);
                }
            }
            f = this.tW(f, 'embed', aF, aa);
        } else {
            f = this.tW(f, '\\w+', aF, aa);
        }
        this.rA = f;
    },
    tW: function(f, ai, aF, aa) {
        function eZ(m, cN, fN, fS) {
            if (aa == '') {
                return cN + fS;
            } else {
                return cN + ' ' + aF + '="' + aa + '"' + fS;
            }
        };
        function fi(m) {
            return m.substring(0, m.length - 1) + ' ' + aF + '="' + aa + '">';
        };
        var P = new RegExp('(<' + ai + '(?=[\\s>])[^>]*?)\\s' + aF + '\\s*?=\\s*?(\w+|\'[^\'>]+\'|\"[^\">]+\")([^>]*>)', 'gi');
        if (P.test(f)) {
            f = f.replace(P, eZ);
        } else {
            if (aa != '') {
                P = new RegExp('<' + ai + '(?=[\\s>])[^>]*>', 'gi');
                f = f.replace(P, fi);
            }
        }
        return f;
    }
};
var DLGTab = {
    Click: function(bG, hp) {
        if ($("tab_nav_" + bG).className == "tab_on") {
            return;
        }
        var mC, co, nZ;
        for (var i = 1; i <= hp; i++) {
            mC = "tab_nav_" + i;
            co = $(mC).getAttribute("_content_id", 2);
            if ($(mC).className == "tab_on") {
                if (!DLGTab.gd) {
                    DLGTab.gd = new Array();
                }
                if (!DLGTab.gd[i]) {
                    DLGTab.gd[i] = {
                        Width: $("tabDialogSize").offsetWidth,
                        Height: $("tabDialogSize").offsetHeight
                    };
                }
                if (!DLGTab.gR) {
                    DLGTab.gR = new Array();
                }
                if (!DLGTab.gR[i]) {
                    DLGTab.gR[i] = {
                        Width: $(co).offsetWidth,
                        Height: $(co).offsetHeight
                    };
                }
                $(mC).className = "tab_off";
                $(co).style.display = "none";
            }
            if (bG == i) {
                nZ = co;
            }
        }
        $("tab_nav_" + bG).className = "tab_on";
        $(nZ).style.display = "";
        try {
            js(bG, hp, nZ);
        } catch(e) {}
    },
    jB: function(nj) {
        var f = '<table class=tab_layout1 border=0 cellpadding=0 cellspacing=0 width="100%"><tr><td>' + '<table class=tab_layout2 border=0 cellpadding=0 cellspacing=0><tr>' + '<td class=tab_begin></td>';
        for (var i = 1; i <= nj.length; i++) {
            var mH = 'tab_on';
            if (i > 1) {
                f += '<td class=tab_sep></td>';
                mH = 'tab_off';
            }
            f += '<td><table id="tab_nav_' + i + '" class="' + mH + '" _content_id="' + nj[i - 1][1] + '" border=0 cellpadding=0 cellspacing=0><tr>' + '<td class=tab_left></td>' + '<td class=tab_center onclick="DLGTab.Click(' + i + ',' + nj.length + ')">' + nj[i - 1][0] + '</td>' + '<td class=tab_right></td>' + '</tr></table></td>';
        }
        f += '</tr></table></td></tr></table>';
        document.write(f);
    }
};
var DLGMFU = {
    lY: function(cc, vR, di, dq, pP) {
        if (this.uI) {
            return;
        }
        this.to = cc;
        this.nG = vR;
        this.tC = pP || '1';
        this.nG.style.width = di;
        this.nG.style.height = dq;
        if (O.ae) {
            if (!dz(true)) {
                this.og(lang["DlgComNotice"] + "<br>" + lang["DlgComMFUMsgNotInstall"]);
                this.CheckInstalled();
                return;
            }
            this.ShowControl();
        } else {
            this.og(lang["DlgComNotice"] + "<br>" + lang["MsgOnlyForIE"]);
            return;
        }
    },
    CheckInstalled: function() {
        if (!dz(false)) {
            window.setTimeout("DLGMFU.CheckInstalled()", 1000);
        } else {
            var f = "<span class=red><b>" + lang["DlgComMFUMsgInstallOk"] + "</b></span><br><br><input type=button class='dlgBtn' value='" + lang["DlgComMFUMsgBtnOk"] + "' onclick='DLGMFU.ShowControl()'>";
            this.og(f);
        }
    },
    og: function(f) {
        this.nG.innerHTML = '<table border=0 cellpadding=0 cellspacing=5 width="100%" height="100%"><tr><td align=center valign=middle>' + '<table border=0 cellpadding=0 cellspacing=5>' + '<tr valign=top>' + '<td><img border=0 src="images/info.gif" align=absmiddle></td>' + '<td>' + f + '</td>' + '</tr>' + '</table>' + '</td></tr></table>';
    },
    ShowControl: function() {
        var jg, jT;
        switch (this.to) {
        case 'image':
            jg = config.AllowImageSize;
            jT = config.AllowImageExt;
            break;
        case 'media':
            jg = config.AllowMediaSize;
            jT = config.AllowMediaExt;
            break;
        case 'flash':
            jg = config.AllowFlashSize;
            jT = config.AllowFlashExt;
            break;
        case 'file':
            jg = config.AllowFileSize;
            jT = config.AllowFileExt;
            break;
        }
        var f = '<table border=0 cellpadding=0 cellspacing=5 width="100%" height="100%" style="background-color:#d4d0c8">' + '<tr>' + '<td style="background-color:#808080;color:#ffffff;padding-left:5px;">' + lang['DlgComMFUMsgAllow'].replace('<ext>', jT).replace('<size>', jg) + '</td>' + '</tr>' + '<tr>' + '<td height="100%">' + '<object id="eWebEditorMFU" classid="CLSID:D8653DCD-2DD5-4648-8498-09868D7AE9A0" codebase="eWebEditor3.CAB#version=3,0,0,0" width="100%" height="100%"></object>' + '</td>' + '</tr>' + '</table>';
        this.nG.innerHTML = f;
        eWebEditorMFU.Lang = lang.ax;
        eWebEditorMFU.SendUrl = A.SendUrl;
        eWebEditorMFU.BlockSize = config.MFUBlockSize;
        eWebEditorMFU.FileType = this.to;
        eWebEditorMFU.AllowSize = jg;
        eWebEditorMFU.AllowExt = jT;
        if (this.tC == '0') {
            eWebEditorMFU.MultiFile = this.tC;
        }
        this.uI = true;
    }
};